Skip to content

Conversation

@hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Jun 8, 2024

Description

I'm testing alpha.18 hi-ogawa/vite-environment-examples#91 and found that import(/* @vite-ignore */ someAboslutePath) is returning a duplicate module. I added a failing test case in this PR.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@sheremet-va
Copy link
Member

sheremet-va commented Jul 19, 2024

This does seem consistent with how Vite works: Vite server expects the URL, but instead, you pass down the full path. The server says that this module doesn't exist:

environment.moduleGraph.getModuleByUrl('/src/basic.js') // exists
environment.moduleGraph.getModuleByUrl('<root>/src/basic.js') // doesn't exist

There is an inconsistency when you call runner.import directly - it will shorten the path to avoid accidental duplicated modules. So we should either make it fail, or also shorten the path for dynamic imports inside the processed code 🤷🏻

It does seem more like a bug because in Node.js this code will work correctly 🤔

@sheremet-va
Copy link
Member

Should be fixed by 01246e5 (#16471)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants